package com.yun.controller;

import com.yun.dao.db.DbDoctor;
import com.yun.dao.db.DbTime;
import com.yun.pojo.Evaluate;
import com.yun.pojo.Schedule;
import com.yun.pojo.db.Doctor;
import com.yun.pojo.db.Time;
import com.yun.service.DirectorService;
import com.yun.service.EvaluateService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;

import java.util.Collection;
import java.util.List;

@Controller
public class DirectorController {
    @Autowired
    DirectorService directorService;
    @Autowired
    EvaluateService evaluateService;
    @Autowired
    DbTime dbTime;
    @Autowired
    DbDoctor dbDoctor;

    @RequestMapping("/toConsult")
    public String toConsult(Model model){
        List<Evaluate> evaluate = evaluateService.queryState(0);
        model.addAttribute("evaluate",evaluate);
        return "director/consult";
    }
    @RequestMapping("/watchList")
    public String watchList(Model model){
        List<Schedule> schedules = directorService.queryName();
        model.addAttribute("schedules",schedules);
        return "director/watchList";
    }
    @RequestMapping("/updateList")
    public String updateList(Model model){

        Collection<Time> setTime = dbTime.getSetTime();
        Collection<Doctor> doctor = dbDoctor.getDoctor();
        model.addAttribute("setTime",setTime);
        model.addAttribute("doctor",doctor);
        return "director/schedule";
    }
    @RequestMapping("/back")
    public String back(Schedule schedule,Model model){
        directorService.updateList(schedule);
        List<Schedule> schedules = directorService.queryName();
        model.addAttribute("schedules",schedules);
        return "director/watchList";
    }
}
